const express = require('express');
const router = express.Router();
const wineController = require('../controllers/wineController');
const { authenticate, requireAdmin, checkUserAccess } = require('../middleware/auth');

// 创建寄存酒记录（管理员）
router.post('/', authenticate, requireAdmin, wineController.createWine);

// 获取寄存酒列表（管理员）
router.get('/', authenticate, requireAdmin, wineController.getWines);

// 获取单条寄存酒记录
router.get('/:id', authenticate, wineController.getWineById);

// 更新寄存酒信息（管理员）
router.put('/:id', authenticate, requireAdmin, wineController.updateWine);

// 取酒操作（管理员）
router.patch('/:id/take', authenticate, requireAdmin, wineController.takeWine);

// 删除寄存酒记录（管理员）
router.delete('/:id', authenticate, requireAdmin, wineController.deleteWine);

// 获取用户寄存酒列表
router.get('/user/:userId', authenticate, checkUserAccess, wineController.getUserWines);

module.exports = router;
